package work;

/**
 * @TODO
 * @Author xu
 * 2025/2/24
 */

import java.util.Scanner;
public class Day3_7 {

    public static void main(String[] args) {
        int targetNumber = (int) (Math.random() * 100) + 1;
        int attempts = 0;
        final int maxAttempts = 7;
        Scanner scanner = new Scanner(System.in);
        System.out.println("请在1到100之间猜一个数字。");
        while (attempts < maxAttempts) {
            System.out.print("请猜一个数字：");
            int userGuess = scanner.nextInt();
            attempts++;
            if (userGuess < targetNumber) {
                System.out.println("太小了，再大一点！");
            } else if (userGuess > targetNumber) {
                System.out.println("太大了，再小一点！");
            } else {
                System.out.println("恭喜你猜对了！");
                break;
            }
            if (attempts == maxAttempts) {
                System.out.println("你太笨了，下次再来吧！" + targetNumber);
            }
        }

        scanner.close();
    }

}
